{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Creating Bayesian networks on a subset of the variables"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this notebook we give an easy method for finding the optimal BN for a subset of the BN variables. First we create a Gobnilp object and read in some data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Using license file /home/james/gurobi.lic\n",
      "Academic license - for non-commercial use only\n",
      "Changed value of parameter PreCrush to 1\n",
      "   Prev: 0  Min: 0  Max: 1  Default: 0\n",
      "Changed value of parameter CutPasses to 100000\n",
      "   Prev: -1  Min: -1  Max: 2000000000  Default: -1\n",
      "Changed value of parameter GomoryPasses to 100000\n",
      "   Prev: -1  Min: -1  Max: 2000000000  Default: -1\n",
      "Changed value of parameter MIPFocus to 2\n",
      "   Prev: 0  Min: 0  Max: 3  Default: 0\n",
      "Changed value of parameter ZeroHalfCuts to 2\n",
      "   Prev: -1  Min: -1  Max: 2  Default: -1\n",
      "Changed value of parameter MIPGap to 0.0\n",
      "   Prev: 0.0001  Min: 0.0  Max: inf  Default: 0.0001\n",
      "Changed value of parameter MIPGapAbs to 0.0\n",
      "   Prev: 1e-10  Min: 0.0  Max: inf  Default: 1e-10\n"
     ]
    }
   ],
   "source": [
    "from pygobnilp.gobnilp import Gobnilp\n",
    "m = Gobnilp()\n",
    "m.learn('discrete.dat',end='data')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can use the `bn_variables` property to get a list of the variables in this data. Normally a BN would be learned for all these variables."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['A', 'B', 'C', 'D', 'E', 'F']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m.bn_variables"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To restrict attention to just the variables B, C, D and F, we just use the `set_bn_variables` method:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['B', 'C', 'D', 'F']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m.set_bn_variables('BCDF')\n",
    "m.bn_variables"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Since the data has already been read in we use the `learn` without supplying a data source and start the learning process from the 'data' stage."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**********\n",
      "BN has score -16917.208027209443\n",
      "**********\n",
      "B<- -4841.285573475907\n",
      "C<- -3501.5105385969146\n",
      "D<-B,C -5104.223974458091\n",
      "F<- -3470.18794067853\n",
      "**********\n",
      "bnlearn modelstring = \n",
      "[B][C][D|B:C][F]\n",
      "**********\n",
      "CPDAG:\n",
      "Vertices: B,C,D,F\n",
      "B->D\n",
      "C->D\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAUCUlEQVR4nO3da2yUZf7G8Wt6opUWqBytrDRRo6CsURCrsIoQJYAFrKgcFQGBYjbZ+MK4utkXu/vGbHZfrW0plNMCVVAsIFGRmCiokdqNQcGVRFZkK+IfEGo5lB7m/+JOgysF2s7M83sO30/SeJhh5oq2F8Nz3/fvicXjcQEAvJFmHQAAooTSBQAPUboA4CFKFwA8ROkCgIcyLvdgv3794oWFhR5FAYBwqKurOxaPx/t39NhlS7ews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5tVdx45JW7a426sDCARK10pmpvT004l92l21Spo6VerbN3m5AKQUpWtp0SJpwwapsbHrv7atze3NZQENCBRK19LgwdLYsdL69V3/tTt2SH36SKNGJT0WgNShdK2VlroTavG4+/riC+ns2Yuf19Ym/etf7jnShdvxMKgcCBRK19r48e5E2e9/77aRDR8uffDBxc87cEAaMUL61a+kP/zBnWqbOdP7vAASQula+uor6ZlnpG+/lf72N1esvXpJvXtf/NzevaWcHHdniJdekn76yV0TrqvzPjeAbsuwDhBZ330nDR3q9te2tl74921t0tVXX/z8q6+Wmprc37e0uL9WV7uFuI8/dhPMAPgen3StFBRIK1dePBWsubnjLWA9ekgZv/g9Mjtb+vOfpbvuSl1OAElF6VqaN0968003BKfd+fNuV0JHfv68q66Sqqrc9V0W04DAoHStjRvn5if07+/+OSvL3ciyIzk57q95edI777CQBgQQpesHw4ZJe/dKgwZd/nktLe7Tbm2tNGaMN9kAJBULaX4xaJC0f7+0efOln7NsmXTbbVJhoWexACQXpesn+fnuljuXMnWqd1kApASXFwDAQ5QuAHiI0vWhwsJC5eTkKC8vT3369NE999yjiooKtbW1WUcDkCBK16e2bdumn376SYcOHdLzzz+vl156SQsud70XQCBQuj7Xu3dvTZkyRa+++qrWrFmjL774wjoSgARQugExatQoDR48WLt27bKOAiABlG6AFBQU6MSJE9YxACSA0g2Q+vp6Xd3RBDIAgUHpBkRtba3q6+s1huO/QKBRuj7X0NCgN998UzNmzNCcOXM0fPhw60gAEsAxYJ8qLi5WRkaG0tLSNGzYMD377LNasmSJdSwACaJ0feibb76xjgAgRbi8AAAeonQBwEOULgB4iNIFAA9RugDgIUoXADxE6QKAhyhdAPAQpQsAHqJ0AcBDlC4AeIjSBQAPUboA4CFKFwA8FIvH45d+MBb7P0mHvIsDAKEwJB6P9+/ogcuWLgAgubi8AAAeonQBwEOULgB4iNIFAA9RugDgof8HCk7RYdbzupIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m.learn(start='data')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It is interesting to compare this network to that learned from the entire set of variables (when there is no restricton on parent set size)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**********\n",
      "BN has score -24028.0947783535\n",
      "**********\n",
      "A<- -5502.137377150637\n",
      "B<-A -3688.9395212202216\n",
      "C<- -3501.5105385969146\n",
      "D<-A,C -3555.014444236549\n",
      "E<-B,F -4310.304956470649\n",
      "F<- -3470.18794067853\n",
      "**********\n",
      "bnlearn modelstring = \n",
      "[A][B|A][C][D|A:C][E|B:F][F]\n",
      "**********\n",
      "CPDAG:\n",
      "Vertices: A,B,C,D,E,F\n",
      "A-B\n",
      "A->D\n",
      "B->E\n",
      "C->D\n",
      "F->E\n",
      "\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV0AAADnCAYAAAC9roUQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAbiUlEQVR4nO3de5zOZf7H8ddtBoOR8zFiaS3JeXYGEZ2UGOucpOKnJCFrNyzbViqxftk2sjqtRiEk4xArGxWSU44R/ZJDThFmxmEG4/798dmpbA4z3HNf3/u+38/HYx5pRjOfNL3nuj/f6/pcPr/fj4iIBEce1wWIiEQSha6ISBApdEVEgkihKyISRApdEZEgir7UB0uWLOmvXLlykEoREQkPa9euPez3+0td6GOXDN3KlSuzZs2a3KlKRCRM+Xy+XRf7mNoLIiJBpNAVEQkiha6ISBApdEVEgkihKyISRApdEZEgUuiKiASRQldEJIgUuiIiQaTQFREJIoWuiEgQKXRFRIJIoSsiEkSeCt3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q/ePiGSTVrpiogEkUJXRCSIFLoiIkGk0BURCSKFrohIECl0RUSCSKErIhJECl0RkSBS6IqIBJFCV0QkiBS6IiJBpNAVEQkiha6ISBApdEVEgsjn9/sv/kGf7xCwK3jliIiEhUp+v7/UhT5wydAVEZHAUntBRCSIFLoiIkGk0BURCSKFrohIECl0RUSC6P8B1JLij/osaiAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "m.set_bn_variables('ABCDEF')\n",
    "m.learn(start='data',palim=None) # no restricton on parent set size"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We get the same conditional independence relations for B, C, D and F in both graphs."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
